﻿using FarPoint.Win.Spread.CellType;
using GrapeCity.Spreadsheet;
using Spread.Common.Features.Sample;
using System;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Text;

namespace Spread.Calculation.Features
{
    public partial class LetFunctionDemo : BaseSampleControl
    {
        public LetFunctionDemo()
        {
            InitializeComponent();
            Name = "Let Function";
            fpSpread.Features.RichClipboard = true;
            fpSpread.Features.ExcelCompatibleKeyboardShortcuts = true;
            fpSpread.AllowCellOverflow = true;
            InitializeBasicUsage();
            InitializeCustomName();
            InitializeNested();
            InitializeSimplify();
            InitializeAggregate();
            InitializePerformance();
            splitContainer1.SplitterDistance = 21;
        }

        private void InitializeBasicUsage()
        {
            IWorksheet ws = fpSpread.AsWorkbook().Worksheets[0];
            ws.Name = "Basic Usage";
            // enable dynamic arrays
            ws.Workbook.WorkbookSet.CalculationEngine.CalcFeatures = CalcFeatures.DynamicArray;
            // create styles for cells
            IStyle titleStyle = ws.Workbook.Styles.Add("title");
            titleStyle.IncludeFont = true;
            titleStyle.Font.Size = 14;
            titleStyle.Font.Bold = true;
            IStyle formulaLabelStyle = ws.Workbook.Styles.Add("formulaLabel");
            formulaLabelStyle.Interior.Color = GrapeCity.Spreadsheet.Color.FromArgb(255, 242, 204);
            formulaLabelStyle.IncludePatterns = true;
            IStyle resultLabelStyle = ws.Workbook.Styles.Add("resultLabel");
            resultLabelStyle.Interior.Color = GrapeCity.Spreadsheet.Color.FromArgb(226, 240, 217);
            resultLabelStyle.IncludePatterns = true;
            IStyle exampleTitleStyle = ws.Workbook.Styles.Add("exampleTitle");
            exampleTitleStyle.Font.Bold = true;
            exampleTitleStyle.IncludeFont = true;
            IStyle formulaExampleStyle = ws.Workbook.Styles.Add("formulaExample");
            formulaExampleStyle.Font.Color = GrapeCity.Spreadsheet.Color.FromArgb(192, 0, 0);
            formulaExampleStyle.IncludePatterns = true;
            // initialize cells
            ws.Cells[0, 0, ws.RowCount - 1, ws.ColumnCount - 1].Font.Name = "Calibri";
            ws.Cells[0, 0, ws.RowCount - 1, ws.ColumnCount - 1].Font.Size = 11;
            ws.Cells["B2"].Text = "LET basic usage";
            ws.Cells["B2"].Style = titleStyle;
            ws.Cells["B4"].Text = "Sample pair variable";
            ws.Cells["B4"].Style = exampleTitleStyle;
            ws.Cells["B5"].Text = "Formula";
            ws.Cells["B5"].Style = formulaLabelStyle;
            ws.Cells["C5"].Formula = "FORMULATEXT(C6)";
            ws.Cells["C5"].Style = formulaExampleStyle;
            ws.Cells["B6"].Text = "Result";
            ws.Cells["B6"].Style = resultLabelStyle;
            ws.Cells["C6"].Formula = "LET(x,2,x+3)";
            ws.Cells["B8"].Text = "Multiple pair variables";
            ws.Cells["B8"].Style = exampleTitleStyle;
            ws.Cells["B9"].Text = "Formula";
            ws.Cells["B9"].Style = formulaLabelStyle;
            ws.Cells["C9"].Formula = "FORMULATEXT(C10)";
            ws.Cells["C9"].Style = formulaExampleStyle;
            ws.Cells["B10"].Text = "Result";
            ws.Cells["B10"].Style = resultLabelStyle;
            ws.Cells["C10"].Formula = "LET(x,1,y,2,z,3,x+y+z=x*y*z)";
            ws.Cells["B12"].Text = "Invoked formula";
            ws.Cells["B12"].Style = exampleTitleStyle;
            ws.Cells["B13"].Text = "Formula";
            ws.Cells["B13"].Style = formulaLabelStyle;
            ws.Cells["C13"].Formula = "FORMULATEXT(C14)";
            ws.Cells["C13"].Style = formulaExampleStyle;
            ws.Cells["B14"].Text = "Result";
            ws.Cells["B14"].Style = resultLabelStyle;
            ws.Cells["C14"].Formula = "LET(x,1,y,2,SUM(x,y))";
            ws.Cells["B16"].Text = "Dynamic Array";
            ws.Cells["B16"].Style = exampleTitleStyle;
            ws.Cells["B17"].Text = "Formula";
            ws.Cells["B17"].Style = formulaLabelStyle;
            ws.Cells["C17"].Formula = "FORMULATEXT(C19)";
            ws.Cells["C17"].Style = formulaExampleStyle;
            ws.Cells["B18"].Text = "Range";
            ws.Cells["B18"].Style = formulaLabelStyle;
            ws.Cells["C18"].Value = 1;
            ws.Cells["D18"].Value = 2;
            ws.Cells["E18"].Value = 3;
            ws.Cells["B19"].Text = "Result";
            ws.Cells["B19"].Style = resultLabelStyle;
            // use Formula2 to set dynamic array formula (otherwise it will be automatically modified with '@' to force single-value return)
            ws.Cells["C19"].Formula2 = "LET(rows,0,cols,0,OFFSET(C18:E18,rows,cols))";
            ws.Cells["C6"].Activate();
        }

        private void InitializeCustomName()
        {
            IWorksheet ws = fpSpread.AsWorkbook().Worksheets.Add("Custom Name");
            IStyles styles = ws.Workbook.Styles; // reuse workbook styles
            ws.Cells[0, 0, ws.RowCount - 1, ws.ColumnCount - 1].Font.Name = "Calibri";
            ws.Cells[0, 0, ws.RowCount - 1, ws.ColumnCount - 1].Font.Size = 11;
            ws.Cells["B2"].Text = "LET local variable & custom name";
            ws.Cells["B2"].Style = styles["title"];
            ws.Cells["B3"].Text = "This sheet includes a custom name \"user\" which is assigned the value \"Michael\"";
            // add worksheet-level custom name
            ws.Names.Add("user", "\"Michael\"");
            //fpSpread.Sheets["Custom Name"].AddCustomName("user", "Michael", 0, 0, true, "Example custom name for LET function");
            ws.Cells["B4"].Text = "Formula";
            ws.Cells["B4"].Style = styles["formulaLabel"];
            ws.Cells["C4"].Formula = "FORMULATEXT(C5)";
            ws.Cells["C4"].Style = styles["formulaExample"];
            ws.Cells["B5"].Text = "Result";
            ws.Cells["B5"].Style = styles["resultLabel"];
            ws.Cells["C5"].Formula2 = "user";
            ws.Cells["B7"].Text = "Always use let local variable first.";
            ws.Cells["B7"].Style = styles["exampleTltle"];
            ws.Cells["B8"].Text = "Formula";
            ws.Cells["B8"].Style = styles["formulaLabel"];
            ws.Cells["C8"].Formula = "FORMULATEXT(C9)";
            ws.Cells["C8"].Style = styles["formulaExample"];
            ws.Cells["B9"].Text = "Result";
            ws.Cells["B9"].Style = styles["resultLabel"];
            ws.Cells["C9"].Formula2 = "LET(user,\"Ivy\",\"The actual user is: \"&user)";
            ws.Cells["B11"].Text = "Use custom name if not available in local variable.";
            ws.Cells["B11"].Style = styles["exampleTitle"];
            ws.Cells["B12"].Text = "Formula";
            ws.Cells["B12"].Style = styles["formulaLabel"];
            ws.Cells["C12"].Formula = "FORMULATEXT(C13)";
            ws.Cells["C12"].Style = styles["formulaExample"];
            ws.Cells["B13"].Text = "Result";
            ws.Cells["B13"].Style = styles["resultLabel"];
            ws.Cells["C13"].Formula2 = "LET(user,user,\"The actual user is: \"&user)";
            ws.Cells["C5"].Activate();

        }

        private void InitializeNested()
        {
            IWorksheet ws = fpSpread.AsWorkbook().Worksheets.Add("Nested");
            IStyles styles = ws.Workbook.Styles; // reuse workbook styles
            ws.Cells[0, 0, ws.RowCount - 1, ws.ColumnCount - 1].Font.Name = "Calibri";
            ws.Cells[0, 0, ws.RowCount - 1, ws.ColumnCount - 1].Font.Size = 11;
            ws.Cells["B2"].Text = "LET nested";
            ws.Cells["B2"].Style = styles["title"];
            ws.Cells["B4"].Text = "Always use the current scope variable.";
            ws.Cells["B4"].Style = styles["exampleTltle"];
            ws.Cells["B5"].Text = "Formula";
            ws.Cells["B5"].Style = styles["formulaLabel"];
            ws.Cells["C5"].Formula = "FORMULATEXT(C6)";
            ws.Cells["C5"].Style = styles["formulaExample"];
            ws.Cells["B6"].Text = "Result";
            ws.Cells["B6"].Style = styles["resultLabel"];
            ws.Cells["C6"].Formula = "LET(var,\"First Scope\",LET(var,\"Second Scope\",var))";
            ws.Cells["B8"].Text = "Use the top scope variable if the variable is not found in the current scope.";
            ws.Cells["B8"].Style = styles["exampleTltle"];
            ws.Cells["B9"].Text = "Formula";
            ws.Cells["B9"].Style = styles["formulaLabel"];
            ws.Cells["C9"].Formula = "FORMULATEXT(C10)";
            ws.Cells["C9"].Style = styles["formulaExample"];
            ws.Cells["B10"].Text = "Result";
            ws.Cells["B10"].Style = styles["resultLabel"];
            ws.Cells["C10"].Formula = "LET(var,\"First Scope\",LET(var,var,var&\"[from the second scope]\"))";
            ws.Cells["C6"].Activate();
        }

        private void InitializeSimplify()
        {
            IWorksheet ws = fpSpread.AsWorkbook().Worksheets.Add("Simplify");
            IStyles styles = ws.Workbook.Styles; // reuse workbook styles
            ws.Cells[0, 0, ws.RowCount - 1, ws.ColumnCount - 1].Font.Name = "Calibri";
            ws.Cells[0, 0, ws.RowCount - 1, ws.ColumnCount - 1].Font.Size = 11;
            ws.Cells["B2"].Text = "LET simplifies complex formulas";
            ws.Cells["B2"].Style = styles["title"];
            ws.Cells["B4"].Text = "Filter the data to show one person";
            ws.Cells["B4"].Style = styles["exampleTltle"];
            ws.Cells["B5"].Text = "Formula";
            ws.Cells["B5"].Style = styles["formulaLabel"];
            ws.Cells["C5"].Formula = "FORMULATEXT(H8)";
            ws.Cells["C5"].Style = styles["formulaExample"];
            //ws.Cells["B6:E6"].Value = new string[,] { { "Rep", "Region", "Product", "Profit"} };
            ws.SetValue(5, 1, new string[,] { { "Rep", "Region", "Product", "Profit" } });
            ws.Cells["B6:E6"].Style = styles.Add("ColumnTitle", styles[BuiltInStyle.Percent20Accent1].Name);
            //ws.Cells["B7:E13"].Value = new string[,] 
            ws.SetValue(6, 1, new string[,]
                {
                    { "Amy", "East", "Apple", "1.33"},
                    { "Fred", "South", "Banana", "0.99"},
                    { "Amy", "West", "Mango", "1.85"},
                    { "Fred", "North", "", "0.82"},
                    { "Fred", "West", "Banana", "1.25"},
                    { "Amy", "East", "Apple", "0.72"},
                    { "Fred", "North", "Mango", "0.54"}
                });
            ws.Cells[9, 3].Value = null;
            ws.Cells["G7"].Text = "Rep";
            ws.Cells["G7"].Style = styles["formulaLabel"];
            ws.Cells["H7"].Text = "Fred";
            ws.Cells["G8"].Text = "Result";
            ws.Cells["G8"].Style = styles["resultLabel"];
            ws.Cells["H8"].Formula2 = "LET(filterCriteria,H7,filteredRange,FILTER(B7:E13,B7:B13=filterCriteria),IF(ISBLANK(filteredRange),\" - \",filteredRange))";
            ws.Cells["B16"].Text = "Generate all weekday dates between May 1, 2020 and May 15, 2020";
            ws.Cells["B16"].Style = styles["exampleTltle"];
            ws.Cells["B17"].Text = "Formula";
            ws.Cells["B17"].Style = styles["formulaLabel"];
            ws.Cells["C17"].Formula = "FORMULATEXT(H18)";
            ws.Cells["C17"].Style = styles["formulaExample"];
            ws.Cells["B18"].Text = "Start";
            ws.Cells["C18"].Text = "01-May-20";
            ws.Cells["B19"].Text = "End";
            ws.Cells["B18:B19"].Style = styles["ColumnTitle"];
            ws.Cells["C19"].Text = "15-May-20";
            ws.Cells["C18"].NumberFormat = ws.Cells["C19"].NumberFormat;
            ws.Cells["G18"].Text = "Result";
            ws.Cells["G18"].Style = styles["resultLabel"];
            ws.Cells["H18"].Formula2 = "LET(dates,SEQUENCE(C19-C18+1,1,C18,1),FILTER(dates,WEEKDAY(dates,2)<6))";
            ws.Columns[2].ColumnWidth = 75;
            ws.Cells["H18:H28"].NumberFormat = ws.Cells["C19"].NumberFormat;
            ws.Columns["H:H"].AutoFit();
            ws.Cells["H8"].Activate();
        }

        private void InitializeAggregate()
        {
            IWorksheet ws = fpSpread.AsWorkbook().Worksheets.Add("Aggregate");
            IStyles styles = ws.Workbook.Styles; // reuse workbook styles
            ws.Cells[0, 0, ws.RowCount - 1, ws.ColumnCount - 1].Font.Name = "Calibri";
            ws.Cells[0, 0, ws.RowCount - 1, ws.ColumnCount - 1].Font.Size = 11;
            ws.Cells["B2"].Text = "Support Engineer Employment Length";
            // create inherited style for Aggregate title with center alignment for merged cell
            ws.Cells["B2"].Style = styles["title"];
            //ws.Cells["B3:E7"].Value = new object[,] 
            ws.SetValue(2, 1, new string[,]
            {
                { "Support Engineer", "Start Date", "Time with Company", "Salary"},
                { "Bob", "5/25/2014", "5+ years", "2790"},
                { "Jim", "7/20/2019", "1-4 years", "2216"},
                { "Kevin", "3/1/2017", "1-4 years", "2498"},
                { "Sarah", "7/14/2020", "< 1 year", "1989"},
            });
            ws.SetValue(3, 4, new int[,] { { 2790 }, { 2216 }, { 2498 }, { 1989 } });
            ws.Cells["B3:E7"].CreateTable(true, "Table2", "TableStyleMedium7");
            ws.Cells["B9"].Text = "Salary Calculations";
            //create combo box cell type for selecting aggregation function
            ComboBoxCellType combo = new ComboBoxCellType();
            combo.EditorValue = EditorValue.ItemData;
            combo.Items = new string[] { "Min", "Max", "Average" };
            combo.ItemData = new string[] { "5", "4", "1" };
            combo.DropDownWhenStartEditing = true;
            combo.StopEditingAfterDropDownItemSelected = true;
            fpSpread.Sheets["Aggregate"].Cells[8, 2].CellType = combo;
            ws.Cells["C9"].Value = 1;
            ws.Cells["D9"].Formula = "LET(data,Table2[Salary],aggregate,C9,SUBTOTAL(aggregate,data))";
            ws.Cells["B10"].Text = "Formula";
            ws.Cells["B10"].Style = styles["formulaLabel"];
            ws.Cells["C10"].Formula = "FORMULATEXT(D9)";
            ws.Cells["C10"].Style = styles["formulaExample"];
            ws.Columns[2].ColumnWidth = 70;
            ws.Cells["D9"].Activate();
        }

        private void InitializePerformance()
        {
            IWorksheet ws1 = fpSpread.AsWorkbook().Worksheets.Add("Performance");
            fpSpread.Sheets["Performance"].TitleInfo.Text = "Using LET Function - Click Recalculate to compare performance (see formula in cell O2)";
            fpSpread.Sheets["Performance"].TitleInfo.Visible = true;
            fpSpread.Sheets["Performance"].RowCount = 501;
            MemoryStream s = new MemoryStream();
            s.Write(Encoding.ASCII.GetBytes(ExcelTemplates.us_500), 0, ExcelTemplates.us_500.Length);
            s.Seek(0, SeekOrigin.Begin);
            fpSpread.Sheets["Performance"].LoadTextFile(s, FarPoint.Win.Spread.TextFileFlags.None, FarPoint.Win.Spread.Model.IncludeHeaders.None, "\r", ",", "\"");
            ws1.Cells["A1:L501"].CreateTable(true, "Table1");
            ws1.Columns[12].ColumnWidth = 4;
            ws1.Cells["N2"].Formula2 = "SORT(UNIQUE(Table1[state]))";
            int rows = (int)ws1.Workbook.WorkbookSet.CalculationEngine.Evaluate("ROWS(SORT(UNIQUE(Table1[state])))", ws1, new GrapeCity.Spreadsheet.CellReference(1, 13)).GetNumber();
            ws1.Cells[1, 14, rows, 14].Formula2 = "LET(cities,ROWS(UNIQUE(FILTER(Table1[city],Table1[state]=$N2,\"\"))),IF(cities<10,\"Less than 10.\",IF(cities<20,\"Between 10 and 19.\",IF(cities<30,\"Between 20 and 29\",\"30 or more.\"))))";
            fpSpread.AddViewport(5, -1, 0);
            fpSpread.SetViewportLeftColumn(5, 1, 13);
            ws1.Cells[1, 14].Activate();

            fpSpread2.AllowCellOverflow = true;
            IWorksheet ws2 = fpSpread2.AsWorkbook().Worksheets[0];
            ws2.Workbook.WorkbookSet.CalculationEngine.CalcFeatures = CalcFeatures.DynamicArray;
            ws2.Name = "Performance";
            fpSpread2.Sheets["Performance"].TitleInfo.Text = "Not using LET Function: see formula in cell O2";
            fpSpread2.Sheets["Performance"].TitleInfo.Visible = true;
            fpSpread2.Sheets["Performance"].RowCount = 501;
            s = new MemoryStream();
            s.Write(Encoding.ASCII.GetBytes(ExcelTemplates.us_500), 0, ExcelTemplates.us_500.Length);
            s.Seek(0, SeekOrigin.Begin);
            fpSpread2.Sheets["Performance"].LoadTextFile(s, FarPoint.Win.Spread.TextFileFlags.None, FarPoint.Win.Spread.Model.IncludeHeaders.None, "\r", ",", "\"");
            ws2.Cells["A1:L501"].CreateTable(true, "Table1");
            ws2.Columns[12].ColumnWidth = 4;
            ws2.Cells["N2"].Formula2 = "SORT(UNIQUE(Table1[state]))";
            ws2.Cells[1, 14, rows, 14].Formula2 = "IF(ROWS(UNIQUE(FILTER(Table1[city],Table1[state]=$N2,\"\")))<10,\"Less than 10.\",IF(ROWS(UNIQUE(FILTER(Table1[city],Table1[state]=$N2,\"\")))<20,\"Between 10 and 19.\",IF(ROWS(UNIQUE(FILTER(Table1[city],Table1[state]=$N2,\"\")))<30,\"Between 20 and 29\",\"30 or more.\")))";
            fpSpread2.AddViewport(-1, 0);
            fpSpread2.SetViewportLeftColumn(1, 13);
            ws1.Cells[1, 14].Activate();

            s.Dispose();
        }

        private void Spread2Enter(object sender, EventArgs e)
        {
            nameBox.Detach();
            formulaTextBox.Detach();
            nameBox.Attach(fpSpread2);
            formulaTextBox.Attach(fpSpread2);
        }

        private void Spread1Enter(object sender, EventArgs e)
        {
            nameBox.Detach();
            formulaTextBox.Detach();
            nameBox.Attach(fpSpread);
            formulaTextBox.Attach(fpSpread);
        }

        private void Spread1ActiveSheetChanged(object sender, EventArgs e)
        {
            if (fpSpread.ActiveSheetIndex == 5)
            {
                SuspendLayout();
                splitContainer3.Panel2Collapsed = false;
                menuStrip.Visible = true;
                ResumeLayout();
            }
            else
            {
                SuspendLayout();
                splitContainer3.Panel2Collapsed = true;
                menuStrip.Visible = false;
                ResumeLayout();
            }
        }

        private void RecalculateToolStripMenuItem(object sender, EventArgs e)
        {
            int t1, t2, t3;

            fpSpread.AsWorkbook().WorkbookSet.CalculationEngine.CalculationOnDemand = false;
            fpSpread2.AsWorkbook().WorkbookSet.CalculationEngine.CalculationOnDemand = false;
            t1 = Environment.TickCount;
            fpSpread.ActiveSheet.RecalculateAll();
            t2 = Environment.TickCount;
            fpSpread2.ActiveSheet.RecalculateAll();
            t3 = Environment.TickCount;
            fpSpread.AsWorkbook().WorkbookSet.CalculationEngine.CalculationOnDemand = true;
            fpSpread2.AsWorkbook().WorkbookSet.CalculationEngine.CalculationOnDemand = true;

            fpSpread.ActiveSheet.TitleInfo.Text = "Using LET Function: " + (t2 - t1).ToString() + " ms (see formula in cell O2)";
            fpSpread2.ActiveSheet.TitleInfo.Text = "Not using LET Function: " + (t3 - t2).ToString() + " ms (see formula in cell O2)";
        }
    }
}


//
//LetFunctionDemo.Designer.cs
//


using FarPoint.Win.Spread;
using System.Windows.Forms;

namespace Spread.Calculation.Features
{
    partial class LetFunctionDemo
    {
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LetFunctionDemo));
            this.menuStrip = new System.Windows.Forms.MenuStrip();
            this.recalculateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
            this.splitContainer2 = new System.Windows.Forms.SplitContainer();
            this.nameBox = new FarPoint.Win.Spread.NameBox();
            this.fpSpread = new FarPoint.Win.Spread.FpSpread(FarPoint.Win.Spread.LegacyBehaviors.AutoRowHeight, ((object)(resources.GetObject("splitContainer2.Panel1.Controls"))));
            this.fpSpread_Sheet1 = this.fpSpread.GetSheet(0);
            this.panel = new System.Windows.Forms.Panel();
            this.formulaTextBox = new FarPoint.Win.Spread.FormulaTextBox();
            this.splitContainer3 = new System.Windows.Forms.SplitContainer();
            this.fpSpread2 = new FarPoint.Win.Spread.FpSpread(FarPoint.Win.Spread.LegacyBehaviors.None, ((object)(resources.GetObject("splitContainer3.Panel2.Controls"))));
            this.fpSpread2_Sheet1 = this.fpSpread2.GetSheet(0);
            this.menuStrip.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
            this.splitContainer1.Panel1.SuspendLayout();
            this.splitContainer1.Panel2.SuspendLayout();
            this.splitContainer1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
            this.splitContainer2.Panel1.SuspendLayout();
            this.splitContainer2.Panel2.SuspendLayout();
            this.splitContainer2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread)).BeginInit();
            this.panel.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit();
            this.splitContainer3.Panel1.SuspendLayout();
            this.splitContainer3.Panel2.SuspendLayout();
            this.splitContainer3.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread2)).BeginInit();
            this.SuspendLayout();
            // 
            // pnlMain
            // 
            this.pnlMain.Size = new System.Drawing.Size(600, 450);
            // 
            // pnlControls
            // 
            this.pnlControls.Size = new System.Drawing.Size(199, 450);
            // 
            // menuStrip
            // 
            this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.recalculateToolStripMenuItem});
            this.menuStrip.Location = new System.Drawing.Point(0, 0);
            this.menuStrip.Name = "menuStrip";
            this.menuStrip.Size = new System.Drawing.Size(800, 24);
            this.menuStrip.TabIndex = 0;
            this.menuStrip.Text = "menuStrip1";
            this.menuStrip.Visible = false;
            // 
            // recalculateToolStripMenuItem
            // 
            this.recalculateToolStripMenuItem.Name = "recalculateToolStripMenuItem";
            this.recalculateToolStripMenuItem.Size = new System.Drawing.Size(79, 20);
            this.recalculateToolStripMenuItem.Text = "&Recalculate";
            this.recalculateToolStripMenuItem.Click += new System.EventHandler(this.RecalculateToolStripMenuItem);
            // 
            // splitContainer1
            // 
            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
            this.splitContainer1.Name = "splitContainer1";
            this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
            // 
            // splitContainer1.Panel1
            // 
            this.splitContainer1.Panel1.Controls.Add(this.splitContainer2);
            this.splitContainer1.Panel1MinSize = 21;
            // 
            // splitContainer1.Panel2
            // 
            this.splitContainer1.Panel2.Controls.Add(this.splitContainer3);
            this.splitContainer1.Size = new System.Drawing.Size(800, 450);
            this.splitContainer1.SplitterDistance = 26;
            this.splitContainer1.TabIndex = 1;
            // 
            // splitContainer2
            // 
            this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer2.Location = new System.Drawing.Point(0, 0);
            this.splitContainer2.Name = "splitContainer2";
            // 
            // splitContainer2.Panel1
            // 
            this.splitContainer2.Panel1.Controls.Add(this.nameBox);
            // 
            // splitContainer2.Panel2
            // 
            this.splitContainer2.Panel2.Controls.Add(this.panel);
            this.splitContainer2.Size = new System.Drawing.Size(800, 26);
            this.splitContainer2.SplitterDistance = 266;
            this.splitContainer2.TabIndex = 0;
            // 
            // nameBox
            // 
            this.nameBox.Dock = System.Windows.Forms.DockStyle.Fill;
            this.nameBox.Location = new System.Drawing.Point(0, 0);
            this.nameBox.MaxLength = 255;
            this.nameBox.Name = "nameBox";
            this.nameBox.Size = new System.Drawing.Size(266, 21);
            this.nameBox.TabIndex = 0;
            // Attach nameBox to fpSpread
            this.nameBox.Attach(this.fpSpread);
            // 
            // fpSpread
            // 
            this.fpSpread.AccessibleDescription = "fpSpread, Sheet1, Row 0, Column 0";
            this.fpSpread.Dock = System.Windows.Forms.DockStyle.Fill;
            this.fpSpread.Font = new System.Drawing.Font("Calibri", 11F);
            this.fpSpread.Location = new System.Drawing.Point(0, 0);
            this.fpSpread.Name = "fpSpread";
            this.fpSpread.Size = new System.Drawing.Size(800, 420);
            this.fpSpread.TabIndex = 0;
            this.fpSpread.ActiveSheetChanged += new System.EventHandler(this.Spread1ActiveSheetChanged);
            this.fpSpread.Enter += new System.EventHandler(this.Spread1Enter);
            // 
            // panel
            // 
            this.panel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.panel.Controls.Add(this.formulaTextBox);
            this.panel.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panel.Location = new System.Drawing.Point(0, 0);
            this.panel.Name = "panel";
            this.panel.Size = new System.Drawing.Size(530, 26);
            this.panel.TabIndex = 0;
            // 
            // formulaTextBox
            // 
            this.formulaTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.formulaTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
            this.formulaTextBox.Location = new System.Drawing.Point(0, 0);
            this.formulaTextBox.Name = "formulaTextBox";
            this.formulaTextBox.ReadOnly = true;
            this.formulaTextBox.Size = new System.Drawing.Size(528, 24);
            this.formulaTextBox.TabIndex = 0;
            // Attach formulaTextBox to fpSpread
            this.formulaTextBox.Attach(this.fpSpread);
            // 
            // splitContainer3
            // 
            this.splitContainer3.BackColor = System.Drawing.SystemColors.ButtonHighlight;
            this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer3.Location = new System.Drawing.Point(0, 0);
            this.splitContainer3.Name = "splitContainer3";
            // 
            // splitContainer3.Panel1
            // 
            this.splitContainer3.Panel1.Controls.Add(this.fpSpread);
            // 
            // splitContainer3.Panel2
            // 
            this.splitContainer3.Panel2.Controls.Add(this.fpSpread2);
            this.splitContainer3.Panel2Collapsed = true;
            this.splitContainer3.Size = new System.Drawing.Size(800, 420);
            this.splitContainer3.SplitterDistance = 400;
            this.splitContainer3.TabIndex = 0;
            // 
            // fpSpread2
            // 
            this.fpSpread2.AccessibleDescription = "fpSpread2, Sheet1, Row 0, Column 0";
            this.fpSpread2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.fpSpread2.Font = new System.Drawing.Font("Calibri", 11F);
            this.fpSpread2.Location = new System.Drawing.Point(0, 0);
            this.fpSpread2.Name = "fpSpread2";
            this.fpSpread2.Size = new System.Drawing.Size(96, 100);
            this.fpSpread2.TabIndex = 0;
            this.fpSpread2.Enter += new System.EventHandler(this.Spread2Enter);
            // 
            // LetFunctionDemo
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.splitContainer1);
            this.Controls.Add(this.menuStrip);
            this.Name = "LetFunctionDemo";
            this.Size = new System.Drawing.Size(800, 450);
            this.Controls.SetChildIndex(this.menuStrip, 0);
            this.Controls.SetChildIndex(this.splitContainer1, 0);
            this.menuStrip.ResumeLayout(false);
            this.menuStrip.PerformLayout();
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
            this.splitContainer1.ResumeLayout(false);
            this.splitContainer2.Panel1.ResumeLayout(false);
            this.splitContainer2.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
            this.splitContainer2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread)).EndInit();
            this.panel.ResumeLayout(false);
            this.splitContainer3.Panel1.ResumeLayout(false);
            this.splitContainer3.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();
            this.splitContainer3.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread2)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }
        #endregion

        private System.Windows.Forms.MenuStrip menuStrip;
        private System.Windows.Forms.SplitContainer splitContainer1;
        private System.Windows.Forms.SplitContainer splitContainer2;
        private System.Windows.Forms.SplitContainer splitContainer3;
        private FarPoint.Win.Spread.FpSpread fpSpread;
        private FarPoint.Win.Spread.SheetView fpSpreadSheet1;
        private System.Windows.Forms.ToolStripMenuItem recalculateToolStripMenuItem;
        private FarPoint.Win.Spread.NameBox nameBox;
        private System.Windows.Forms.Panel panel;
        private FarPoint.Win.Spread.FormulaTextBox formulaTextBox;
        private FarPoint.Win.Spread.FpSpread fpSpread2;
        private FarPoint.Win.Spread.SheetView fpSpread2Sheet1;
        private SheetView fpSpread_Sheet1;
        private SheetView fpSpread2_Sheet1;
    }
}
